package org.jeecg.demo.wx.controller;

import org.jeecg.common.api.vo.Result;
import org.jeecg.demo.wx.aspect.WXTokenAuthAspect;
import org.jeecg.demo.wx.util.COSUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * 功能描述
 * 文件上传控制器
 *
 * @author: zgq
 * @date: 2024年02月01日 16:46
 */
@RestController
@RequestMapping("wx/file")
public class WXFileUploadController {
    @Autowired
    private COSUtil cosUtil;

    public  String FILE_BASE_DIR;

    @PostMapping("/upload/img")
//    @WXTokenAuthAspect
    public Result<String> uploadImg(MultipartFile file) {
        try {
            Result<String> result = cosUtil.uploadFile(file);
            return result.success("图片上传成功");
        } catch (IOException e) {
            return Result.error("图片上传失败");
        }
    }

    @PostMapping("/upload/file")
//    @WXTokenAuthAspect
    public Result<String> uploadFile(MultipartFile file) {
        return Result.ok("文件上传成功");
    }
}
